home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Floppyshop 2
/
Floppyshop - 2.zip
/
Floppyshop - 2.iso
/
art&graf.ix
/
art-0074
/
qrt
/
qrt_doc.txt
< prev
next >
Wrap
Text File
|
1997-04-16
|
103KB
|
3,367 lines
Introduction to the QRT
Ray Tracer
QRT is a ray tracing image rendering system that runs under a
variety of operating systems. It has a free format input
language with extensive error detection and reporting
capabilities.
This manual is divided into several sections as follows:
QRT Language Reference:
This is a quick reference guide to the QRT command
language. It can suffice as a tutorial for those familiar
with ray tracing programs, or function as a guide to QRT
features not described in the User Manual.
QRT User Manual:
The User Manual is a more complete tutorial to the QRT
system. It describes the basic commands and features of
QRT, without listing every possible command or option. It
would be a good starting place for beginners. QRT bugs
and desired enhancements are listed at the end of this
section.
QRT Sample Programs
These are actual QRT input files; they show suggested QRT
indenting style and give examples of various features.
Machine Specifics
The QRT post processor is machine dependent. This section
contains instructions on using it, as well as information
on other machine dependent features.
QRT Ray Tracer Page 1 Introduction
References
Howard Anton, Elementary Linear Algebra, Anton Textbooks,
Inc., 1987
David F. Rogers, Procedural Elements for Computer Graphics,
McGraw Hill, Inc., 1985
Eric Graham, Graphic Scene Simulations, Amiga World, CW
Communications/Peterborough, Inc., May/June 1987
QRT Ray Tracer Page 2 Introduction
Table of Contents
Page
I. QRT Language Reference Manual
A. Introduction .......................... 1
B. Setup Commands ......................... 3
1. Sky ................................. 3
2. Ground .............................. 3
3. Focal Length ........................ 4
4. First Scan .......................... 4
5. Last Scan ........................... 5
6. File Name ........................... 5
7. Observer ............................ 6
8. Lamp ................................ 7
C. Primitive Types ........................ 8
1. Sphere .............................. 8
2. Parallelogram ....................... 9
3. Triangle ............................ 10
4. Ring ................................ 11
5. Quadratic ........................... 12
D. Patterned Surfaces ..................... 14
1. Pattern ............................. 14
2. Rectangle ........................... 16
3. Circle .............................. 17
E. Bounding Boxes ......................... 18
1. Begin Bbox .......................... 18
2. End Bbox ............................ 18
F. Instances .............................. 19
1. Begin Instances ..................... 19
2. End Instances ....................... 20
3. Instance Of ......................... 21
G. Setting Defaults ....................... 22
1. Default ............................. 22
QRT Ray Tracer Page 3 Introduction
Table of Contents - Cont.
Page
II. QRT Users Manual
A. Introduction .......................... 1
B. Comparison to Other Systems ............ 1
C. The World .............................. 2
D. Input Language ......................... 3
E. Illumination Model ..................... 4
F. Light Sources .......................... 6
G. Observer ............................... 7
H. Filenames .............................. 8
I. Sky and Ground ......................... 8
J. Bounding Boxes ......................... 9
K. Patterns ............................... 10
L. Instances .............................. 12
M. Defaults ............................... 13
N. Problems, Bugs ......................... 14
O. Possible Enhancements .................. 14
QRT Ray Tracer Page 4 Introduction
QRT Language Reference
INTRODUCTION
This document is a reference guide to the QRT command language.
One section is devoted to each QRT command. All parameters to
commands are listed.
More information on QRT can be found in the User's Manual and
Technical Reference Manual.
The following table lists syntax used in this document:
TEXT MEANING EXAMPLE RANGE
(x,y,z) floating pt vector (10, -20, 30.56) all
(r,g,b) color value triple (0, .5, 1.00) 0 to 1
i an integer 12 0 to 127
n floating pt number -123.4 all
p positive float 123.4 >0
string text string FOO_BAR ASCII
Each section of this document contains one or more of the
following sub-sections:
QRT Ray Tracer Page 1 Language Reference
Command Type : OPTIONAL or REQUIRED
Parameters (required) : Lists required parameters
Parameters (optional) : Lists optional parameters
Optional Forms : Alternatives for parameter names. Ex:
'horiz' = 'horizon' means either can
be used as a parameter name.
Example : An example of the command (with all
required parameters, but not
necessarily all optional ones.
Restrictions : Things not to do
See also : Similar commands
QRT has a free format input language, and parameters can be given
in any order.
QRT Ray Tracer Page 2 Language Reference
QRT Misc. Setup Commands
SKY:
Command type: OPTIONAL
The SKY command is used to specify the color of all rays that
don't hit any other object. The sky is black by default. The
sky color at the zenith (up), and horizon can be specified,
and QRT will blend the colors in between as smoothly as
possible. In addition, dithering can be specified.
Parameters (optional):
zenith = (r,g,b) : the color of the zenith
horiz = (r,g,b) : the color at the horizon
dither = i : dithering
Optional forms:
'horiz' = 'horizon'
Example:
SKY ( horiz = (0, 0, .6),
zenith = (0, 0, .4),
dither = 5
)
See also : GROUND
GROUND:
Command type: OPTIONAL
QRT does not have a specific ground command. Instead, use a
large parallelogram with an optional pattern.
PARALLELOGRAM ( loc = (-10000, 0, -10000),
v1 = ( 20000, 0, 0),
v2 = ( 0, 0, 20000),
pattern = PATTERN_OF_CHOICE
)
See also : PARALLELOGRAM
QRT Ray Tracer Page 3 Language Reference
FOC_LENGTH:
Command type: OPTIONAL
This sets the focal length of QRT's "camera". The default is
50, but it can be changed with this command. As with 35mm
photography, larger numbers result in a 'telephoto' effect,
and smaller numbers will result in wide angle (and distorted)
views.
Example:
FOC_LENGTH = 70
Restrictions:
0 < FOC_LENGTH
FIRST_SCAN:
Command type: OPTIONAL
By default, QRT generates an image with the same resolution as
your screen. However, it can be instructed to create a
partial image by using this command and LAST_SCAN. This
feature may not be supported, depending on your QRT post
processor. First scan should be less than the Y resolution of
your screen.
Example:
FIRST_SCAN = 100
Restrictions:
0 < FIRST_SCAN < y-resolution
See also : LAST_SCAN
QRT Ray Tracer Page 4 Language Reference
LAST_SCAN:
Command type: OPTIONAL
This command is similar to FIRST_SCAN. LAST_SCAN should be
less than the Y resolution of your screen.
Example:
LAST_SCAN = 300
Restrictions:
0 < LAST_SCAN < y-resolution
See also : FIRST_SCAN
FILE_NAME:
Command type: REQUIRED
This is used to set the output file for QRT, which will be
read by the post processor. The file name will be mapped to
upper case. Some restrictions may arise from file naming
conventions on specific computers.
Example:
FILE_NAME = QRT_IMAGE.RAW
QRT Ray Tracer Page 5 Language Reference
OBSERVER:
Command type: REQUIRED
OBSERVER tells QRT where the observer is located, and his
direction of view. The view direction is specified by giving
the coordinates he should look at. In addition, the observer
UP vector may be given. This is, by default, (0,1,0).
Parameters (required):
loc = (x,y,z) : location of observer
lookat = (x,y,z) : point of interest
Parameters (optional):
up = (x,y,z) : up vector
Optional forms:
'loc' = 'pos' = 'location' = 'position'
Example:
OBSERVER ( loc = (0, 0, 0),
lookat = (100, 0, 0)
)
Restrictions:
The observer cannot look in the direction of the up
vector.
'lookat' cannot be equal to 'loc'.
'up' must have non-zero length.
QRT Ray Tracer Page 6 Language Reference
LAMP:
Command type: OPTIONAL
Lamps are sources of light in QRT. They can be placed
anywhere, and emit any color and intensity of light. The
ambient light value is the color of the lamp. The distance
parameter is the minimum distance from the lamp that objects
will be illuminated at full intensity. Most objects should be
farther from the lamp than this value, or else they will be
washed out. The radius parameter is ignored by this version
of QRT, but may eventually be used to implement penumbral
shadows.
Parameters (required):
loc = (x,y,z) : location of object
dist = p : distance of max illumination
Parameters (optional):
amb = (r,g,b) : ambient light
radius = p : radius
Optional forms:
'loc' = 'pos' = 'location' = 'position'
Example:
LAMP ( loc = (12,34,56),
radius = 123.4,
)
QRT Ray Tracer Page 7 Language Reference
QRT Primitive Types
SPHERE:
Command type: OPTIONAL
SPHERE creates a sphere with a given location, radius, and
surface characteristics.
Parameters (required):
loc = (x,y,z) : location of object
radius = p : radius
Parameters (optional):
name = string : name for object
pattern = string : pattern name to attach
amb = (r,g,b) : ambient light
diff = (r,g,b) : diffuse reflection
trans = (r,g,b) : transmission
mirror = (r,g,b) : mirror reflection
fuzz = i : currently unused
index = p : index of refraction
dither = i : dithering
sreflect= p : Phong specular refl. coeff.
reflect = p : percent specular reflection
Optional forms:
'loc' = 'pos' = 'location' = 'position'
Example:
SPHERE ( loc = (100, 100, 50.234),
radius = 123.4,
diff = (1.00, .20, .20)
)
QRT Ray Tracer Page 8 Language Reference
PARALLELOGRAM:
Command type: OPTIONAL
This command creates a parallelogram with a given location,
shape, and surface characteristics. Two vectors define the
shape of the parallelogram (they need not be orthogonal).
Parameters (required):
loc = (x,y,z) : location of object
v1 = (x,y,z) : vector for side one
v2 = (x,y,z) : vector for side two
Parameters (optional):
name = string : name for object
pattern = string : pattern name to attach
amb = (r,g,b) : ambient light
diff = (r,g,b) : diffuse reflection
trans = (r,g,b) : transmission
mirror = (r,g,b) : mirror reflection
fuzz = i : currently unused
index = p : index of refraction
dither = i : dithering
sreflect= p : Phong specular refl. coeff.
reflect = p : percent specular reflection
Optional forms:
'loc' = 'pos' = 'location' = 'position'
'vect1' = 'v1'
'vect2' = 'v2'
Example:
PARALLELOGRAM ( loc = (10, 20, 50),
vect1 = (20, 0, 0),
vect2 = ( 0, 0, 50),
diff = (0, .90, .20)
)
QRT Ray Tracer Page 9 Language Reference
TRIANGLE:
Command type: OPTIONAL
The TRIANGLE command (similar to PARALLELOGRAM) creates a
triangle shape. Two vectors define the sides of the triangle.
Parameters (required):
loc = (x,y,z) : location of object
v1 = (x,y,z) : vector for side one
v2 = (x,y,z) : vector for side two
Parameters (optional):
name = string : name for object
pattern = string : pattern name to attach
amb = (r,g,b) : ambient light
diff = (r,g,b) : diffuse reflection
trans = (r,g,b) : transmission
mirror = (r,g,b) : mirror reflection
fuzz = i : currently unused
index = p : index of refraction
dither = i : dithering
sreflect= p : Phong specular refl. coeff.
reflect = p : percent specular reflection
Optional forms:
'loc' = 'pos' = 'location' = 'position'
'vect1' = 'v1'
'vect2' = 'v2'
Example:
TRIANGLE ( loc = (52, 21, 50),
vect1 = (10, 5, 0),
vect2 = ( 0, 8, 20),
diff = ( 0, 0, 0),
mirror = ( 1, 1, 1)
);
QRT Ray Tracer Page 10 Language Reference
RING:
Command type: OPTIONAL
RING creates a ring (annulus), which is a circle with a smaller
circle cut out of it. If the innder radius is zero, the ring
will be a simple circle. Two vectors define the plane of the
annulus, as with RING and PARALLELOGRAM.
Parameters (required):
loc = (x,y,z) : location of object
v1 = (x,y,z) : vector one
v2 = (x,y,z) : vector two
rad_1 = p : inner radius
rad_2 = p : outer radius
Parameters (optional):
name = string : name for object
pattern = string : pattern name to attach
amb = (r,g,b) : ambient light
diff = (r,g,b) : diffuse reflection
trans = (r,g,b) : transmission
mirror = (r,g,b) : mirror reflection
fuzz = i : currently unused
index = p : index of refraction
dither = i : dithering
sreflect= p : Phong specular refl. coeff.
reflect = p : percent specular reflection
Optional forms:
'loc' = 'pos' = 'location' = 'position'
'vect1' = 'v1'
'vect2' = 'v2'
Example:
RING ( loc = (52, 21, 50),
v1 = (10, 5, 0),
v2 = ( 0, 8, 20),
rad_1 = 10,
rad_2 = 20,
)
Restrictions:
0 < rad_1 < rad_2
QRT Ray Tracer Page 11 Language Reference
QUADRATIC:
Command type: OPTIONAL
This command creates a quadratic surface given by the
equation:
2 2 2
a x + b y + c z = d
The coefficients a,b,c and d can be specified. This primitive
can be used to create cylinders, cones, oblong spheroids,
etc. Several min and max parameters specify the maximum
extents of the surface.
Parameters (required):
loc = (x,y,z) : location of object
a = n
b = n
c = n
d = n
xmax = n
xmin = n
ymax = n
ymin = n
zmax = n
zmin = n
Parameters (optional):
name = string : name for object
pattern = string : pattern name to attach
amb = (r,g,b) : ambient light
diff = (r,g,b) : diffuse reflection
trans = (r,g,b) : transmission
mirror = (r,g,b) : mirror reflection
fuzz = i : currently unused
index = p : index of refraction
dither = i : dithering
sreflect= p : Phong specular refl. coeff.
reflect = p : percent specular reflection
Optional forms:
'loc' = 'pos' = 'location' = 'position'
QRT Ray Tracer Page 12 Language Reference
Example:
{ ** vertical cylinder ** }
QUADRATIC ( loc = (57, 21.2, 0),
a = 1,
b = 0,
c = 1,
d = 100
);
Restrictions:
a != 0 or b != 0 or c != 0
QRT Ray Tracer Page 13 Language Reference
Patterned Surfaces
PATTERN:
Command type: OPTIONAL
This command creates a pattern definition which can be
attached to any primitive object. A pattern is a two
dimensional array than can be mapped to the surface of any
primitive. Patterns must be defined before they are used. The
PATTERN keyword serves two functions: to create a pattern
definition, and to attach this definition to a primitive. The
correct meaning is found by context: if the PATTERN keyword
appears in a primitive definition followed by a name, it is
assumed to refer to a predefined pattern. However, if PATTERN
occurs outside any primitive definition, it is assumed to be a
pattern definition. If all the pattern definitions are
grouped at the top of the file, they will always be defined
before they are used.
A pattern is defined by giving it a size, a name, and one or
more sub-pattern definitions. There are currently two types
of sub-patterns: CIRCLE and RECTANGLE. The sub-pattern list
can be of any length (although long lists will slow the ray
tracer), and can use several of each type of sub-pattern
primitive.
The X and Y size parameters specify the size of the pattern;
the pattern will be repeated over the surface of an object
each X or Y units in the indicated direction. These size
units are arbitrary, since the pattern can be given a new size
when attached to an object.
In each sub-pattern, any object surface characteristics can be
specified. If a given ray hits this sub-pattern, the surface
will be colored as indicated. If it does not hit any sub
pattern in the list, the objects default surface
characteristics will be used. The example below defines a
red-checkered pattern. The background color of the object to
which this pattern is attached will determine the color of the
other checker box in the pattern.
Parameters (required):
name = string : name for pattern
x_size = p : x size of pattern
y_size = p : y size of pattern
QRT Ray Tracer Page 14 Language Reference
Parameters (optional):
CIRCLE = circle_defn : CIRCLE sub-pattern - see
reference for CIRCLE
RECTANGLE = rect_defn : RECTANGLE sub-pattern - see
reference for RECTANGLE
Optional forms:
'loc' = 'pos' = 'location' = 'position'
Example:
PATTERN ( x_size = 16,
y_size = 16,
name = CHECK,
RECTANGLE (
start_x = 0, start_y = 0,
end_x = 8, end_y = 8,
diff = (1.00, .20, .20);
)
RECTANGLE (
start_x = 8, start_y = 8,
end_x = 16, end_y = 16,
diff = (1.00, .20, .20);
)
)
This pattern can now be attached to an object as follows:
SPHERE ( { ** sphere definition here ** }
pattern = CHECK,
xmult = .5,
ymult = .5
)
Where the xmult and ymult parameters specify a new size
for the pattern.
Restrictions:
At least one sub-pattern must appear.
If two sub-patterns overlap in a region, the last one
defined will be used in this region.
See also : RECTANGLE, CIRCLE
QRT Ray Tracer Page 15 Language Reference
RECTANGLE:
Command type: OPTIONAL
RECTANGLE is a type of sub-pattern.
Parameters (required):
start_x = p : start position for rectangle
start_y = p
end_x = p : end position for rectangle
end_y = p
Parameters (optional):
amb = (r,g,b) : ambient light
diff = (r,g,b) : diffuse reflection
trans = (r,g,b) : transmission
mirror = (r,g,b) : mirror reflection
fuzz = i : currently unused
index = p : index of refraction
dither = i : dithering
sreflect= p : Phong specular refl. coeff.
reflect = p : percent specular reflection
Example:
RECTANGLE (
start_x = 10, start_y = 12,
end_x = 15, end_y = 15,
diff = (1.00, .20, .20);
)
Restrictions:
RECTANGLE should be used only within a pattern definition.
start_x < end_x
start_y < end_y
See also : PATTERN
QRT Ray Tracer Page 16 Language Reference
CIRCLE:
Command type: OPTIONAL
CIRCLE is a type of sub-pattern.
Parameters (required):
radius = p : radius
Parameters (optional):
amb = (r,g,b) : ambient light
diff = (r,g,b) : diffuse reflection
trans = (r,g,b) : transmission
mirror = (r,g,b) : mirror reflection
fuzz = i : currently unused
index = p : index of refraction
dither = i : dithering
sreflect= p : Phong specular refl. coeff.
reflect = p : percent specular reflection
Example:
CIRCLE (
radius = 5,
diff = (1.00, .20, .20);
)
Restrictions:
CIRCLE should be used only within a pattern definition.
See also : PATTERN
QRT Ray Tracer Page 17 Language Reference
Bounding Boxes
BEGIN_BBOX:
Command type: OPTIONAL
The BEGIN_BBOX, END_BBOX commands form an enclosing bounding
box around a group of objects (which may include other
bounding boxes). An optional name must precede the bounding
box begin statement. Bounding boxes cannot be given surface
characteristics, since they are conceptual objects.
Parameters (optional):
name = string : name for box
Example:
name = SAMPLE_BBOX
BEGIN_BBOX
SPHERE (); { ** sphere here ** }
TRIANGLE (); { ** triangle here ** }
END_BBOX
Restrictions:
Must be paired with an END_BBOX statement.
END_BBOX:
Command type: OPTIONAL
Companion command to BEGIN_BBOX.
Example:
name = SAMPLE_BBOX
BEGIN_BBOX
SPHERE (); { ** sphere here ** }
TRIANGLE (); { ** triangle here ** }
END_BBOX
Restrictions:
Must be paired with a BEGIN_BBOX statement.
QRT Ray Tracer Page 18 Language Reference
Instances
BEGIN_INSTANCES:
Command type: OPTIONAL
Several primitives may be grouped into an 'instance', and this
group can easily be placed in several locations. In addition,
it can be resized. All instance definitions must be placed
within the BEGIN_INSTANCES and END_INSTANCES statements; only
one set of these statements is allowed. A group of objects
must be placed in a BBOX, and this BBOX must be given a name.
In the following example, three objects are defined: OBJECT_1,
SUB_OBJECT_1, and OBJECT_2. Any inclusion of OBJECT_1 will
implicitly include SUB_OBJECT_1, but not OBJECT_2. Any
arbitrary object tree can be included. Referring to a node
will include the sub-tree rooted at that node.
Example:
BEGIN_INSTANCES
NAME = OBJECT_1
BEGIN_BBOX
{ ** some primitives here ** }
NAME = SUB_OBJECT_1
BEGIN_BBOX
{ ** some more primitives here ** }
END_BBOX
END_BBOX
NAME = OBJECT_2
BEGIN_BBOX
{ ** more primitives ** }
END_BBOX
END_INSTANCES
Restrictions:
There can be only one BEGIN_INSTANCES statement.
See also: END_INSTANCES, INSTANCE_OF
QRT Ray Tracer Page 19 Language Reference
END_INSTANCES:
Command type : OPTIONAL
This command specifies the end of the instance tree. Any
primitive after the END_INSTANCES statement are actually
displayed as part of the image.
Restrictions:
There can be only one END_INSTANCES statement.
See also: BEGIN_INSTANCES, INSTANCE_OF
QRT Ray Tracer Page 20 Language Reference
INSTANCE_OF:
Command type: OPTIONAL
After an instance tree is defined with the BEGIN_INSTANCES,
END_INSTANCES command pair, parts of the tree can be referred
to with the INSTANCE_OF statement. This actually puts the
sub-tree in the image. You must specify the name of the root
of the sub-tree. The original instance should be defined
relative to (0,0,0), and the location parameter specifies
where the new copy will go.
Parameters (required):
name = string : name of sub-tree
loc = (x,y,z) : location for instance
Parameters (optional):
scale = (x,y,z) : scale factor
Example:
INSTANCE_OF ( name = OBJECT_1,
loc = (100.23, 20.23, 45.678),
scale = (.5, .5, .5)
)
Optional forms:
'loc' = 'pos' = 'location' = 'position'
Restrictions:
All scale factor entries should be greater than zero.
If the scale factor entries are unequal, some primitives
in the instance will not be affected correctly. For
example, a SPHERE will remain round if scaled by
(1,2,3), not change to a QUADRATIC spheroid.
See also : BEGIN_INSTANCES, END_INSTANCES
QRT Ray Tracer Page 21 Language Reference
Setting Defaults
DEFAULT:
Command type: OPTIONAL
QRT sets certain defaults for the color attributes of a
surrface. The standard default is for a white, non
reflective, non shiny, non transparent surface with a medium
amount of dithering. These defaults can be changed with the
DEFAULT command. More than one DEFAULT command can be
included, in which case each one affects all primitives after
it and before the next DEFAULT or the end of the file. In
addition to new surface characteristics, the NO_SHADOW keyword
instructs QRT not to compute shadow information for the scene.
This can decrease image generation time at the expense of
image quality.
Parameters (optional):
no_shadow : QRT will not compute
shadow information
amb = (r,g,b) : ambient light
diff = (r,g,b) : diffuse reflection
trans = (r,g,b) : transmission
mirror = (r,g,b) : mirror reflection
fuzz = i : currently unused
index = p : index of refraction
dither = i : dithering
sreflect = p : Phong specular refl. coeff.
reflect = p : percent specular reflection
Example:
DEFAULT ( no_shadow, { ** no shadowing ** }
diff = (1, 0, 0) { ** default = red objects **
}
)
QRT Ray Tracer Page 22 Language Reference
QRT Users Manual
INTRODUCTION
QRT (Quick Ray Tracer) is an easy to use image generation system
that uses a ray tracing algorithm for image rendering. Versions
exist for the Amiga personal computer and Data General MV10000.
QRT overcomes many of the problems of other ray tracing packages,
and is designed to operate nicely in a multi-tasking environment.
COMPARISON TO OTHER SYSTEMS
QRT was developed on the Amiga personal computer, so it will be
compared to other Amiga ray tracers. There are, to my knowledge,
five other Amiga ray tracers, each with its own strengths and
weaknesses. I will describe each system briefly, and compare it
to QRT. All the Amiga ray tracers can operate in HAM (4096
color) mode.
RT: RT was the first ray tracer written for the Amiga, by Eric
Graham. It will model a universe made of only spheres, a
sky, and a checkered or solid ground. It is relatively
fast, but not generally useful for realistic modeling
because of the sphere limitation. The input language is
cryptic, although some error checking is done. The system
will only generate low resolution images.
SILVER: I have never seen SILVER, so I cannot say much about
this system.
SCULPT-3D: This package incorporates an interactive editor for
creating objects, and is capable of quickly generating a
preliminary image of the scene by using hidden surface
techniques. However, every primitive is made of polygons,
and some primitives such as spheres require hundreds of
polygons for a smooth texture, so the ray tracing is very
slow. Also, the package takes a large amount of memory to
run, and is prone to system crashes. Its chief feature is
the ability to create arbitrary shaped objects using a
series of triangles. Mirrored, dull, or shiny objects are
supported.
CLIGHT: This ray tracer also has an interactive editor, but
produces very poor quality images. It is not capable of
any patterning or reflection characteristics.
QRT Ray Tracer Page 1 User Manual
DBW: This is possibly the most complete ray tracer for the
Amiga. It will support objects with arbitrary degrees of
reflection and gloss, depth of field effects, some
texturing, wavy surfaces, fractals, transparent surfaces,
diffuse propagation of light from object to object, and 5
primitive types (sphere, triangle, parallelogram, fractal,
and ring). The input language, however, is so cryptic as
to be nearly incomprehensible, and if there is any error
in the input file, it will crash the system. It is also
painfully slow; some images take 16 to 24 hours to
complete.
QRT is meant to be a compromise between the fast, simple ray
tracers and the slow powerful systems. It compares favorably in
speed to RT, and in power to Sculpt-3d or DBW. It has a very
friendly input language with extensive error checking. Here are
some features of QRT:
o Multiple primitive types, including user defined quadratic
surfaces
o Arbitrary levels of diffuse reflection, spectral
reflection, transmission, ambient lighting, and gloss
o User defined pattern information for objects
o Bounding boxes for groups of objects
o Shadows
o Multiple light sources with different characteristics
o Arbitrary Phong spectral reflection coefficients
o Color dithering to increase the apparent number of colors
o Easy to use, free format input language with error
checking. Parameters are by keyword and may appear in any
order.
o Supports medium resolution (128k dots/screen)
Each of these features of QRT will be discussed is greater detail
in this document.
THE QRT WORLD
QRT constructs an image of the world by performing certain
manipulations on an internal representation of a group of
QRT Ray Tracer Page 2 User Manual
objects. You must provide a description of these objects to QRT
through the QRT input language.
QRT writes a machine independent bitmap file which can be read by
a computer specific post processor. The post processor either
displays the image or converts it into the proper form for
display by system programs. (See the Machine Dependent
Information section of this manual for details).
QRT is capable of dealing with 5 types of primitive objects:
spheres, parallelograms, triangles, rings (annulus), and
quadratic surfaces. The latter can be used to model cones,
oblong spheroids, and other interesting surfaces. Each of these
objects can have an arbitrary orientation in space, and arbitrary
surface characteristics.
QRT INPUT LANGUAGE
The QRT input language is free format, in that commands may be
placed anywhere on a line, and newlines may be placed at any
point. This makes it easy to use indentation. Comments are also
supported by surrounding text with curly braces '{' and '}'.
Comments may span lines.
Once a file with QRT commands is built (using any available text
editor), qrt can be made to process these commands:
QRT <commands.qrt
where "commands.qrt" is the file containing the input. QRT also
produces some statistics, so this output can also be redirected.
Since QRT runs for a long time, you will probably want to run it
as a background task with a low priority. So, the full set of
commands to run QRT would be:
SetTaskPriority -5
run QRT <commands.qrt >qrt.out
SetTaskPriority 0
This set of commands is specific to the Commodore Amiga; see the
Machine Dependent Information section of the manual for other
operating systems.
QRT will write a very large file, which may be anywhere from 400K
to 4 megabytes depending on the specific computer display
resolution. (See the Machine Dependent Information section of
this manual for the exact file size). There should be at least
enough room on your disk to accommodate this file. I recommend
sending the output to a RAM disk, so that the physical disk does
QRT Ray Tracer Page 3 User Manual
not get used for 60 minutes while QRT computes the image.
A typical QRT command to create a sphere using the default
surface attributes would, be:
SPHERE ( loc = (5,10,100) { this is a white sphere }
radius = 12.5
)
For comparison, the sphere command for DBW looks like this:
s 0 0 0 1 0 0 0 .2 .2 .2 .8 .8 .8 5 10 100 12.5
Or, in RT, the command would be:
<1,1,1> 2 (5,10,100):1;
The QRT input should be much easier to understand. If QRT sees
an error in its input file, it will stop and print the line
number of the offending line, along with a descriptive error
message (ILLEGAL PARAMETER, etc).
The QRT input language is not case sensitive. A full description
of the language and a shorter, context free grammar can be found
elsewhere in this manual.
THE QRT ILLUMINATION MODEL
Before meaningful images can be created, the QRT illumination
model must be understood. The light that reaches the observer
from each object is composed of several components:
o Diffuse light - The "color" of the object
o Ambient light - The color of the light that falls on
the surface of the object if no lamps
are shining on this spot. Note that
this specifies the color of light, not
the color of the object itself.
o Reflected light - If the object acts as a mirror, some
light is reflected.
o Specular highlights - The "bright spots" of a shiny object
viewed in a light.
o Transmitted light - The object may transmit some of the
light that strikes the back of the
object (glass surfaces)
QRT Ray Tracer Page 4 User Manual
All of these light characteristics can be specified for any
object. If none are specified, the current defaults are assumed.
These defaults can be changed (see DEFAULT in Language Reference
Guide).
Most of these light characteristics deal with a percentage of
light. For example, a light may reflect 80% of the red light
that strikes it, 20% of the green, and 40% of the blue. This is
the "color" of the object (diffuse light), and would be specified
in QRT by the following syntax:
diff = (.80, .20, .40)
In QRT, 1.00 is 100%. The language is also free-format, so the
above is equivalent to:
diff = (.80,
.20,
.40 )
The commas between parameters are optional, but make the input
easier to read. Semicolons can also be used.
Ambient light is specified in a similar manner:
amb = (.20, .20, .20)
The ambient light values should be fairly small. Most of the
light hitting the object comes from lamps, but some parts of the
object may be in the shadow of another object. If no ambient
light is specified, these shadows will appear totally black,
which looks unrealistic. Ambient light will give the affect of a
small amount of light hitting areas in a shadow, producing a more
realistic looking image.
Reflection is specified using the MIRROR attribute:
mirror = (.90, .90, .90)
If a true mirrored surface is desired, the mirror values should
be fairly high. If one of the values has a higher value than the
others, the mirror will appear red, green, or blue.
Transmission is specified as follows:
trans = (.80, .80, .80)
index = 120
Note the addition of another parameter, the index of refraction.
An explanation of the index of refraction for an object is beyond
QRT Ray Tracer Page 5 User Manual
the scope of this document - see a book on elementary optics for
details.
In addition, specular highlights are specified with two
parameters:
reflect = .50,
sreflect = 45
"REFLECT" is the percentage of light reflected in the specular
highlight, and sreflect is the Phong spectral reflection
coefficient. Again, an explanation of the Phong coefficient is
beyond the scope of this document; however, a higher value for
the coefficient will result in smaller, tighter highlights for a
more metallic looking object. Lower values of sreflect should be
accompanied by lower values in reflect, and will produce duller
looking surfaces, such as paper.
QRT also accepts a dithering amount for each object:
dither = 3
Dithering is a mechanism for simulating colors not available on
the display by blending other colors. The default dithering
coefficient is 3; it should be kept small. Values of 1 to 6 are
good. Larger objects should employ more dithering, and mirrored
or glass objects should have little or no dithering.
QRT also accepts an attribute "FUZZ", but this is not used in the
present implementation. In a future implementation of QRT, FUZZ
will effect small, random perturbations of the normal vector at a
given location on an object. This will simulate rough surfaces,
matted glass, or imperfectly reflecting mirrors.
All of the above light characteristics may be attached to any
object. The default is for a white, non reflecting, non
transmitting dull surface with an average amount of dithering. In
addition, any of the above color information (which will be
referred to from now on as COLORINFO) may also be attached to a
pattern structure (see the PATTERN section of this document).
LIGHT SOURCES
Light sources in QRT are called "LAMPS". The lamp structure is
simple:
LAMP ( loc = (12, 34, 56),
dist = 50,
radius = 10 )
QRT Ray Tracer Page 6 User Manual
The default is for a bright white lamp, but if you wish to change
this, you can specify different values for the lamp's ambient
light. The radius value is ignored by this implementation of
QRT, but it must be supplied. In a future version, the radius
may be used to implement penumbral shadows. I didn't include
them in this version, since they take a very long time to
compute, and don't add much to the image quality.
The "dist" entry in the lamp structure specifies at what distance
the light from the lamp is at full intensity. Beyond this value,
the light will decrease in intensity. This value should be set
so that the nearest object in the scene is slightly more than
"dist" distance units from the lamp. This does not have to be
exact. If objects are nearer than dist" units, they will be so
bright that shading will not take place. Objects very far away
will be dimly illuminated.
By the way, QRT distance units are not tied to any real world
unit. They can stand for feet, nautical miles, or furlongs, at
your choice.
THE OBSERVER
After defining the world, you must tell QRT the position and
orientation of the observer. This is done as follows:
OBSERVER ( loc = (0, 10, 20),
lookat = (5, 5, 120),
up = (0, 1, 0)
)
The x,y, and z are the location of the observer. The "lookat"
variables give a location in space that the observer is looking
at. Most ray tracers require you to give two angles for the
observers view direction, but it is MUCH easier to know the
location of an object or point in space you wish the observer to
look at. This will be the center of your scene.
The "up" variables define which direction is up. Usually, you
will wish to use the values given above. QRT uses a right hand
coordinate system: positive y is up, positive z is out of the
screen, and positive x is to the right if you are looking in the
negative z direction. The "up" parameter is optional, and if
omitted, defaults to (0,1,0).
QRT will generate an error message if no observer is defined.
QRT Ray Tracer Page 7 User Manual
OUTPUT FILENAME
QRT places its output in a file, so you must give it the name of
this file:
FILE_NAME = outfile.tmp
This file must observe any file naming restrictions of the
operating system and computer you are using. See the Machine
Dependent Information section of this manual for information on
file naming restrictions.
FOCAL LENGTH
This is the focal length of the "lens" used by the observer.
Think of it as a 35mm camera lens - higher numbers produce a
telephoto effect, and smaller numbers are for wide angle lenses.
Note that small numbers may produce some distortion of the image
around the edges.
FOC_LENGTH = 60
SCAN RANGE
If you do not want QRT to produce a whole image, you can specify
the first and last scan lines. The parameters should be less
than the maximum Y resolution of your display.
FIRST_SCAN = 100
LAST_SCAN = 300
This is useful for quickly generating part of an image.
SKY AND GROUND
QRT has facilities for generating the sky and ground. To define
the sky, you must give it two colors - one for the sky overhead
(zenith), and one for the horizon:
SKY ( zenith = (.10, .2, .4),
horiz = (.10, .2, .65),
dither = 6
)
QRT Ray Tracer Page 8 User Manual
This will produce a blue sky, with a brighter color near the
horizon. (The sky need not be blue - it could be red or hot
pink, or vary from red to green). QRT will smoothly blend the
colors from the zenith to the horizon. Since the sky is so
large, you may want to specify a greater amount of dithering to
compensate for the displays color resolution limit.
The SKY structure will also produce sky colors below the horizon;
any ray that does not strike an object will strike the SKY. To
fix this, define a ground. There is no dedicated GROUND command,
since you can define a very large parallelogram with the same
effect. You can make it brown with patches of green using a
PATTERN, or checkered green and yellow in the classic ray-tracing
ground pattern.
BOUNDING BOXES
QRT supports the use of bounding boxes to speed the ray tracing
process. For images composed of only a few (1 to 3) objects,
bounding boxes will not do much to increase speed. However, for
images where there are groups of objects physically close to each
other, they can greatly reduce execution times. A bounding box
is a conceptual structure that encloses a group of objects. When
the ray tracer is finding line/object intersections, if a line
does not strike a bounding box, it cannot possibly strike any
objects within that bounding box. This saves the ray tracer the
trouble of checking intersections with all objects within the
box. In the case where the ray DOES enter the box, some
additional overhead is incurred; however, this cost is easily
justified by reduced times for negative tests.
Bounding boxes can occasionally be useful for complex objects,
such as quadratic surfaces, when the object is fairly small.
Since the time to find the intersection with a quadratic surface
is large, but bounding box intersections are fast, the ray tracer
can save time for all the negative tests.
QRT Ray Tracer Page 9 User Manual
Bounding boxes can contain other bounding boxes, in a recursive
manner. This recursive structure defines an "object tree". There
are two keywords that define the beginning and end of a bounding
box: BEGIN_BBOX and END_BBOX. Here is an example:
{ ** QRT Code for a chessman ** }
BEGIN_BBOX
QUADRATIC ( { ** quadr defn ** }
)
QUADRATIC ( { ** quadr defn 2 ** }
)
SPHERE ( { ** sphere defn ** }
)
BEGIN_BBOX
SPHERE ( ) { ** two spheres ** }
SPHERE ( )
END_BBOX
END_BBOX
This structure may be nested to an arbitrary level; if you had a
closely spaced group of chessmen, you could enclose all of them
with a bounding box.
PATTERNS
QRT permits user defined patterns which can be mapped to the
surface of any object. A pattern is basically an organized
method for changing an object's COLORINFO over the surface of
that object. For example, a checkered surface can be created, or
a surface given the appearance of brick or tile. The current
patterning in QRT is limited, yet powerful enough to describe
many common patterns.
A pattern is composed of a series of sub-patterns. Each
sub-pattern defines a region on the surface of an object which
will contain a given COLORINFO. These regions are presently
limited to rectangles, but this may be expanded in a future
implementation of QRT.
QRT Ray Tracer Page 10 User Manual
A pattern can be defined once, and used for many objects. For
example, a brick pattern might be defined:
PATTERN ( name = BRICK,
{ ** other pattern info here ** }
)
SPHERE ( { ** sphere definition ** }
pattern = BRICK
)
PARALLELOGRAM ( { ** parallelogram definition ** }
pattern = BRICK
)
This example ignores what is actually in the pattern definition
to demonstrate how patterns are attached to objects. A pattern
must be defined before it can be used. It is given a name, such
as BRICK, and any object can specify this pattern with "PATTERN =
BRICK". There are no practical restrictions on the length of
pattern names (if your computer has 1 megabyte of ram, you cannot
have a pattern name longer than 1 million characters). Multiple
patterns may be defined at the top of an input file, and used for
any object in the file.
What exactly makes up a pattern, you ask? A pattern can be
viewed as a rectangle that is repeated over the surface of an
object. If the pattern size is 10 x 10, and you have an object
(say a parallelogram) that is 50 x 50, the pattern will repeat 5
times in each direction. Within this repeating rectangle, sub
patterns can be defined. A sub-pattern is a rectangle or circle
within the pattern rectangle with a certain COLORINFO. Any number
of these sub-patterns can be created within one pattern
definition. To create a brick wall, you might define several
sub-patterns, each with a slightly different color of red or
brown. The sub patterns need not cover the entire pattern
rectangle; if they do not, the COLORINFO you defined for the
object is used instead of the pattern COLORINFO. If you defined
sub-patterns for bricks, the area not covered would be mortar,
and the objects COLORINFO would define the color of the mortar.
An actual brick pattern is given in appendix C. The proper use
of patterns can be very effective in producing realistic looking
scenes. However, complicated patterns will slow image creation,
so it is recommended that you first display test scenes with no
patterns, and then add pattern information when the scene is
right.
QRT Ray Tracer Page 11 User Manual
INSTANCES
Often, several copies of a complex object must be created.
Specifying their component primitives each time would be
difficult. There is a solution to both these problems: INSTANCES.
An INSTANCE is a method by which several primitives (actually, an
arbitrary object tree) can be grouped and given a name. Copies
of these objects may be easily created with one command. Here is
an example of an instance definition.
BEGIN_INSTANCES
NAME = object1
BEGIN_BBOX
{ ** a bunch of primitives here ** }
END_BBOX
NAME = object2
BEGIN_BBOX
{ ** a bunch more primitives here ** }
NAME = spheres
BEGIN_BBOX
SPHERE ( ) { ** two sphere definitions ** }
SPHERE ( )
END_BBOX
END_BBOX
END_INSTANCES
There can be only one of these instance definitions, and it must
appear before any instances are used. However, any arbitrary
object tree can appear within the begin/end instance statements.
Several instances are now available for use. For example:
INSTANCE_OF ( name = object1,
loc = (100, 10, 20),
)
INSTANCE_OF ( name = spheres,
loc = (12.3, 24.5, 999)
)
This example shows that any named portion of the object subtree
can function as an instance (the "spheres" object is at a lower
level than the "object1' object). The "offset" parameters are
required. They specify a new position for the instance (offset
from the origin). In the instance definition segment, all
objects are defined relative to 0,0,0. They can then be moved in
the INSTANCE_OF statement with the offset command.
QRT Ray Tracer Page 12 User Manual
In addition, the instance can be given a new size:
INSTANCE_OF ( name = object2,
loc = (200, 100, 50),
scale = (1.5, 2.0, .25)
)
The scale factors are optional, and are given the default of 1.
The instance will be resized by the indicated amount in each of
the directions. Note that there are some restrictions to this:
if spheres are given a different scale factor in each direction,
they will remain spheres (not change to QUADRATIC types). The
new radius will be the old radius scaled by the smallest of the
scale factors.
DEFAULTS
Each object in QRT is given certain default surface light
characteristics (see the section on surface characteristics). If
these defaults are not suitable, they can be changed with the
DEFAULT command:
DEFAULT ( diff = (1.00, .1, .1)
no_shadow )
This will make all future objects red unless specified otherwise.
More than one default command can be used in a file: each one
affects all the objects created after it, but before the next
default command. Any light characteristics can be changed
(MIRROR, DITHER, etc).
In addition, the keyword "no_shadow" can be included (as above).
Ordinarily, QRT computes shadow information for all objects. This
takes a lot of time, especially for scenes composed of many
objects and many lamps. The "no_shadow" command causes QRT to
bypass the shadow routines. This will result in a much faster
image generation time, but the picture will not look as
realistic.
QRT Ray Tracer Page 13 User Manual
PROBLEMS WITH QRT
There are several limitations in this version of QRT:
o Patterning does not work well with some quadratic
surfaces. This is a problem with the 3d to 2d mapping
function used for quadratics.
o Patterns do not support circular or non-orthogonal
rectangular sub-patterns. This would slow pattern
processing but increase the utility of patterns.
o User defined texturing is not implemented - all objects in
QRT appear smooth. I have some ideas on how to add
textures to objects, but these have not been tested and
are not incorporated into this version of QRT.
o Some rounded objects such as spheres appear distorted if
they are near the edge of the image. This is a bug in the
routine that creates a ray for a given pixel position.
FUTURE ENHANCEMENTS TO QRT
The following are some things I'd like to add to QRT:
o Enhanced patterning capability. This could include
arbitrary polygonal patterns, and non-orthogonal shapes.
Also, the ability to use enumerated (bit-mapped) patterns
as well as analytic patterns would be useful.
o Anti-dithering routines. These routines are very
computationally expensive (they can increase image
generation times by a factor of 3 to 5), so they were not
included in this version.
o Penumbral shadows. This is also very computationally
expensive for a minimal utility level, so I didn't bother
to include this feature.
o Fractal generation. Fractals are, again, computationally
expensive, but some things, such as mountains, cannot be
modeled with a ray tracer any other way.
o Wavy surfaces. This is useful for modeling water, rippled
mirrors, etc. I know how to do it, I just didn't have
time to add it yet. It would be nice if the waves were
user definable in amplitude and x and y wavelength. Wavy
surfaces are very similar in implementation to textures.
QRT Ray Tracer Page 14 User Manual
o Snowy surfaces. This is an idea from DBW, which adds snow
to a surface depending on its slope and altitude.
o Interpolated normal surfaces. This is a mechanism to
model arbitrary curved surfaces by using a polygonal
approximation to the surface, and interpolating the normal
vector between surfaces to avoid angular looking surfaces.
o Image plane object lists. This is a technique for
increasing the speed for positive line/object intersection
test. (Bounding boxes increase speed for negative
line/object intersection tests).
o Heuristics for faster completion of images using area
coherence.
o An interactive editor. This is another large scale
project in itself, and I can't forsee having time to do it
for a long time, but it would be useful. The editor would
display a preliminary image of the scene, and when the
user had placed objects to his satisfaction, it would
write a QRT input file and call QRT as a background task.
There are certain problems here - for instance, how do you
quickly generate the outline of a user defined quadratic
that can take many forms (cone, spheroid, etc)? And how
can the user easily specify the object tree structure
(bounding boxes) with an interactive editor?
QRT Ray Tracer Page 15 User Manual
Addendum to QRT Version 1.2
The following are changes to QRT made since version 1.1
Additions and Enhancements
Polygon Primitive Added to Pattern Command
Patterns in version 1.1 could include only rectangles and
circles; a new polygon command vastly increases the
utility of the pattern command. Polygons may have any
number of points (at least three), but a large number of
points will increase the time
taken for the containment test, and hence the time to
complete the image. A fast containment algorithm is used,
but it is still linear in the number of points in the
polygon. A practical limit
might be 30 to 40 points (split amoung all polygons in the
pattern).
In order for the polygon command to operate correctly, the
first point must be the same as the last point. ex:
PATTERN ( name = TRIANGLE_TEST
x_size = 6
y_size = 6
POLYGON (
POINT = (0 , 0)
POINT = (5 , 0)
POINT = (2.5,5)
POINT = (0 , 0) { same as 1st pt }
{ ** any number of additional points
could be added here ** }
)
{ ** more polygons or other pattern
primitives could come here ** }
)
Polygon primitives may be mixed in a pattern with either
circles or rectangles. If a rectangle is desired, the
rectangle primitive is faster than a four point polygon.
QRT Ray Tracer Page 1 Addendum to 1.2
Bug Report
One bug found in version 1.1 has been fixed. The shadowing
routine in version 1.1 did not operate quite correctly: a
point was (incorrectly) computed as being in a shadow if a
line drawn from the point to the lamp intersected an object
even on the other side of the lamp. The test should have
looked at objects only on the same side of the lamp as the
point in question. This was giving extra shadows in strange
places, and has been fixed in this version.
Planned extentions for 1.3
Version 1.3 will probably include a better lexical analyser
that can cope with nested comments and possibly #include
files. The #include directive would enable one to amass a
file of often used patterns, for example. The parser is
plenty fast enough (between 2 and 3 hundred lines per second
from RAM:) to make this practical.
Hints, Tips, etc.
Try using a general purpose macro processor to pre-process QRT
input. #define BRICK_RED (.8, .2, .1), for example, or use
parameter macros to #define CYLENDER (height, diameter) to
elimiate the need for entering quadratic coeficcients. (I may
add CYLENDER, CONE, and SPHEREOID commands to a future version
of QRT. They would simply map into the current quadratic
primitive, but make QRT easier to use).
QRT Ray Tracer Page 2 Addendum to 1.2
Addendum to QRT Version 1.3
The following are changes to QRT made since version 1.2
Additions and Enhancements
'Remove' Command Added
The 'REMOVE' command was added to allow sections of a
planar primitive to be removed. This makes it much easier
to create flat objects that are not shaped like QRT's
planar primitives. For example, I had a QRT input file
which created the image of a grand piano. The top of the
piano, because of its complex shape, initially was created
from 11 planar primitives. Now, it is only
1 PARALLELOGRAM primitive, and a section of the
parallelogram is removed to create the shape of a piano
top.
Before the REMOVE command can be used, a pattern must be
created using any of QRT's pattern primitives (the piano
uses a polygon).
This pattern need not be given any surface characteristics
- it simply defines the region to be removed from the
planar primitive. The pattern is attached to the
primitive in exactly the same way as a normal pattern,
except that the REMOVE command is used instead of the
PATTERN command:
PARALLELOGRAM ( loc = (0, 0, 0)
v1 = (10, 0, 0)
v2 = (0, 0, 10)
diff = (1, 0, 0)
remove = SECTION_TO_REMOVE
pattern = ANY_PATTERN
)
This example shows that the PATTERN command can be used on
the same primive as the REMOVE command.
Several things should be noted about the REMOVE command.
First, the pattern defines the sections to remove, not the
sections which will remain. In the piano example, the
pattern mapped all of the parallelogram except the part
that composed the actual piano top. Second, even though
QRT Ray Tracer Page 1 Addendum to 1.3
the remove command can be used with the curved surface
primitives (SPHERE, QUADRATIC), the results will not be
quite right. To use the sphere as an example, the front
surface of the sphere would have the correct pattern
removed from it, but the back surface of the sphere would
be completely gone. This is because the SPHERE intersect
routine ignores completely the back surface of the sphere.
I will probably fix this in a future version.
Nested Comments
Comments may now be nested. This makes it easier to
comment out blocks of QRT code which themselves contain
comments.
Planned extentions for 1.4
I had planned to create an "#INCLUDE" command for version 1.3,
but instead I worked on the REMOVE command (it seemed more
important). #INCLUDE will probably be coming next time.
QRT Ray Tracer Page 2 Addendum to 1.3
Addendum to QRT Version 1.4
The following are changes to QRT made since version 1.3
Additions and Enhancements
Transmission
Transmission of light through surfaces now works, allowing
one to model glass surfaces. Some additions to and
changes from the original grammar were necessary to
provide the desired functionality. A new keyword,
"DENSITY", has been added, and the function of the old
"TRANS" keyword has been changed. Also, a "THRESHOLD"
parameter has been added to the default structure. Since
transmission is a complex operation, this entire Addendum
will discuss aspects of modeling glass surfaces.
The DENSITY keyword
It was my previous intent that the TRANS keyword would
specify the percent transmission of light though the
surface. After thinking a little more about the nature of
light transmission, it was clear that this wasn't
adequate. The amount of light transmitted depends not
only on a fixed coefficient of the surface, but on the
thickness of the surface. For example, a hollow glass
sphere will appear darker (transmit less light) near the
edges, where the glass is thickest. To account for this
effect, the "DENSITY" keyword was added. Density
specifies what percentage of transmitted light will be
removed per unit distance travelled though the object.
For example, the following density attribute would remove
2 percent of all light per unit distance:
DENSITY = (.02, .02, .02);
If a sphere, at its widest point, was 10 units thick, 20
percent of the light would be removed. Near the edge of
the sphere, less light would be removed.
Since density is a function of distance, the same density
factor will have different effects on objects of different
sizes. To remove the same percentage of light from an
object half as thick, double the density factor.
QRT Ray Tracer Page 1 Addendum to 1.4
Shadows from Transparent Surfaces
The old "TRANS" keyword still exists, but it performs a
different function. It does not affect the appearance of
the object, but rather, the attenuation of light passed
through the surface. QRT knows how glass surfaces bend
light, and so it can model the magnifying effects of
looking through curved glass, etc. But for computing
shadows, it cannot properly bend the light from lamps.
This means that you can model lenses that the observer
looks through, but not lenses used to focus light. In
order to provide some attenuation effects, use "TRANS" to
tell QRT how much light is passed through the surface.
This information is ONLY used for computing shadows. For
example, blue glass should cast a blue shadow. Use
something similar to:
TRANS = (0, 0, .7)
to cast a blue shadow (this lets 70 percent of the blue
light pass). Note that by using strange combinations of
DENSITY and TRANS, you can model illogical objects which
appear, for example, blue, but cast a red shadow. These
shadows will be entirely of one intensity, and will not
vary with the thickness of the glass.
Using MIRROR with Transparent surfaces
Glass surfaces not only refract light, but also reflect a
percentage of it. This means that to realistically model
glass, the glass should reflect a small percentage of the
light. Try starting with 20 to 25 percent reflection.
Note that all glass objects reflect light from both the
outside and the inside surfaces of the glass.
Index of Refraction
The index of refraction for an object governs how much the
light is bent upon entering or exiting the object. A
higher index will bend the light more. The index of
refraction of air is 1.00, and for glass is roughly 1.33.
Some substances, such as diamond, have a higher index.
Modeling Hollow Objects
When designing the QRT transmission routines, I wanted to
be able to model both solid glass and hollow glass
objects. To understand how this is done, it is necessary
to understand a little about how QRT's transmission model
works.
QRT Ray Tracer Page 2 Addendum to 1.4
A ray, after leaving the observer, has two states: either
it is inside a glass object, or it is outside. The ray
starts out outside. When it first encounters a glass
surface, it is bent, and its state is toggled from OUTSIDE
to INSIDE. It continues on until encountering another
surface, whereupon it is bent again, and its state is once
more toggled. This has several implications for modeling
glass. The first is that ALL glass surfaces MUST have two
sides - that is, once the ray enters the glass, there must
be no way for it to exit without again passing through a
surface. The second is that a ray must go from glass to
air, or air to glass, but not from glass with index of
refraction A to glass with index of refraction B; i.e, the
two glass surfaces cannot touch each other, even though
they may be placed very close together.
As an example of how this works, consider a solid glass
sphere. The ray encounters the sphere, and is bent (in
this case, towards the normal vector). QRT now remembers
that the ray is INSIDE a glass surface. The ray
continues on until it hits the back side of the sphere,
whereupon it is bent (away from the normal vector), and
its state is toggled to OUTSIDE. In summary, the
INSIDE/OUTSIDE flag tells QRT how to bend the ray.
Consider now the case of a hollow glass sphere. This is
modeled using two concentric spheres, one with a smaller
radius. The ray will first hit the outside sphere, be
bent, and have its state toggled to INSIDE. There are now
two possible cases. First, the ray may miss the inside
sphere, in which case the simulation proceeds as in the
above paragraph. Second, it may hit the inside sphere.
In this case, it is bent, and its state is toggled to
OUTSIDE. The ray is now considered to be back in air, so
that the inside sphere has modeled the hollow portion of
the glass. In a similar manner, the ray reaches the other
side of the inside sphere, enters the glass again, and
finally leaves the outside sphere. Note that even though
the inside sphere is thought of as the "air" in the center
of the object, it MUST have the same index of refraction
as the outside sphere. This is necessary so that QRT can
correctly bend the light when it exits the glass.
Chromatic Aberration
In QRT, all rays, regardless of color, are refracted
exactly the same. This is contrast to the real world, in
which the amount the light is bent depends on its
wavelength. This appears, so far as I can tell, to be a
bug in the real world, and I saw no reason to include it
in a ray tracer.
QRT Ray Tracer Page 3 Addendum to 1.4
Threshold attribute
A new keyword, THRESHOLD, has been added to the default
structure. In previous versions of QRT, there was a
mechanism for detecting infinite recursion provided that
objects reflected less that 100 percent of the light
reaching them. QRT stopped the recursion when the
intensity of the light reached 1 percent of its original
value. When transmission was added, I made this value
adjustable. With glass objects, both surfaces reflect
light, and if QRT waits until the 1 percent mark before
stopping recursion, the time necessary to complete the
image is greatly increased with little or no increase in
image quality. The default is now 10 percent, and is
changeable as follows:
DEFAULT ( threshold = .05
)
This would stop recursion when the intensity reaches 5
percent of the original value. An added effect is that if
the objects surface reflects (or transmits) less than the
threshold amount of light, the reflection or transmission
will be ignored completely.
Affect of Glass on Speed
Unfortunately, the presence of any glass objects will slow
the ray tracer down. This effect may range from barely
noticeable, for few, small objects to excruciatingly
miserably slow, for many, large objects. Sorry, there is
nothing I can do to speed it up - the 68000 simply won't
go any faster. The reason for the
slowdown is that for every ray/glass surface intersection,
TWO additional rays must be sent out (as opposed to one,
for reflection). And remember, each ray intersects a
glass object twice: once on the way in, and once on the
way out. Also, the two generated rays may intersect the
glass, as well. You can see how this process could get
very slow.
Notes, etc.
Watch for control characters in the QRT input file. I had
accidentally imbedded an invisible control character in a file
I was working on, and the QRT parser refused to parse the
file. After closely checking the file, I began to look for a
bug in the parser code. Finally, I discovered the control
character, but only after spending 1 hour checking the parser
code. The QRT parser will generate a SYNTAX ERROR, CODE 207
QRT Ray Tracer Page 4 Addendum to 1.4
upon encountering any special characters in the input file.
Since transmission involves heavy recursion, don't forget to
set the default stack size to something larger than the
default 4000 bytes. A stack size of 40000 to 50000 bytes
seems safe for most images.
Notes on Multitasking
The following discussion is not at all QRT specific, but it is
here just to clear up some confusion many people have about
multitasking.
There has been some discussion to the effect that multitasking
is either: a) not useful at all (just ask Apple/Mac type
folks), or b) useful only as a mechanism for loading more than
one interactive program at once and switching between them
(said/believed by many Amiga folks). While for some people
this may be true, for anyone who runs ray tracers, mandelbrot
set program, or down/uploads programs from a BBS, multitasking
holds great benefits. Try this: run QRT on the Amiga, in the
background, with a low task priority. Now forget about it,
and do whatever else you wanted to do (run a text
editor/spreadsheet/terminal prog, etc). Now, run a ray tracer
on an IBM or MAC II, and you'll very quickly tire of staring
at the machine while it thinks.
The key to getting the maximum benefit from multitasking, (and
this is what many people don't realize), is being able to
specify task priorities. Non interactive, number crunching
tasks should be given a low priority (try -5). This will give
any interactive tasks all the CPU time they want. By lowering
the priority of the background tasks, the editor or
spreadsheet or compiler will run just as fast as it would have
without the background task. If the background task is run
with the SAME priority as the foreground task (editor, etc),
the foreground task will run noticeably slower. Don't ever
run a task such as a ray tracer with a HIGHER priority as the
CLI or interactive task. Doing so will cause the interactive
task to stop dead until the ray tracer has finished.
One more note on multitasking for programmers: do try to write
nice, friendly programs that give up the CPU when they don't
need it. Number crunching programs typically need all the CPU
time they can get; however, interactive programs do not. If
you wish to wait, use the timer device, not a for loop. This
has two advantages: 1) it doesn't hog the CPU, and 2) the
elapsed time will be relatively independent of how busy the
CPU is. There is nothing more annoying than some little
calculator or notepad program that wants ALL the CPU time,
causing low priority tasks to stop. Even some commercial
QRT Ray Tracer Page 5 Addendum to 1.4
software houses have committed this fault (witness some
popular paint programs or terminal programs).
OK, enough preaching about multitasking. I hope this has
cleared up the issue for anyone who was confused.
QRT Ray Tracer Page 6 Addendum to 1.4